Why I am getting Presentation Error [on hold]
Posted
by
user105697
on Programmers
See other posts from Programmers
or by user105697
Published on 2013-10-22T13:57:29Z
Indexed on
2013/10/22
16:02 UTC
Read the original article
Hit count: 143
c
Below is my code. When I submit it in UVA they are giving me Presentation error. I want to know the reason.
I have tried all possible ways. In my code I use 2D-array to store each word of a sentence. I also want to know the reason for giving presentation error.
#include<stdio.h>
#include<string.h>
int main()
{
char a[10000],ar[100][10000];
int i,j,k,m,n,l,len[10000],c;
freopen("input.txt","r",stdin);
while(gets(a))
{
k=0;
i=0;
c=0;
for(j=0; ; ++k)
{
if(a[k]==' ' || a[k]=='\0')
{
ar[i][j]='\0';
len[i]=c;
if(a[k]=='\0') break;
i++;
j=0;
c=0;
}
else
{
ar[i][j]=a[k];
c++;
j++;
}
}
for(m=0; m<=i; m++)
{
for(n=(len[m]-1); n>=0; n--)
{
printf("%c",ar[m][n]);
}
printf(" ");
}
printf("\n");
}
return 0;
}
© Programmers or respective owner